<#include "/common/head.html"/>
    
    <table id="dg"></table>
    <div id="tb" style="padding:2px 5px;">
               <div class="wrap_search">		        		
			            	<span class="search_item">
				            	<span class="item_text">物料编号: </span>
				            	<span class="item_obj">
				            		<input class="easyui-textbox" type="text" name="mat_no" id="mat_no" value=""/>
				            	</span>    
				            </span>
			            	<span class="search_item">
				            	<span class="item_text">物料名称: </span>
				            	<span class="item_obj">
				            		<input class="easyui-textbox" type="text" name="mat_name" id="mat_name" value=""/>
				            	</span>    
				            </span>
				            <span class="search_item">
				            	<span class="item_text">物料规格: </span>
				            	<span class="item_obj">
				            		<input class="easyui-textbox" type="text" name="mat_std" id="mat_std" value=""/>
				            	</span>    
				            </span>
				           <span class="search_item search_between">
				                <span class="item_text">入库时间: </span>
				                <span class="item_obj">
				                    <input class="easyui-datebox" name="_start_in_time" value=""/> ～ <input class="easyui-datebox" name="_end_in_time" value=""/>
				                </span>
				            </span>				      
		            	<span class="search_item">
			            	<span class="item_text">所属仓库: </span>
			            	<span class="item_obj">
			            		<input class="easyui-combobox" name="storage_name" id="storage_name" value="" style="width:100px" data-options="
			            				valueField: 'id',
        								textField: 'text',
			            				data: [
			            					{id:'', text:'-请选择-'}<#list dictDataOfStorage.keySet() as key>,{id:'${key}', text:'${dictDataOfStorage.get(key)}'}</#list>
			            				]
			            			" />
			            	</span>    
			           	 </span>
			        
			<div id="searchBtnWrap" style="float:right; padding-right:5px;">
                <a href="javascript:void(0)" class="easyui-linkbutton color1" iconCls="glyphicon-search" onclick="zcurdSearch(this)">搜索</a>
                <a href="javascript:void(0)" class="easyui-linkbutton color2" iconCls="glyphicon-repeat" onclick="flushPage()">重置</a>
            </div>
         </div>   
    </div>
    

<script type="text/javascript">
var datagrid = $("#dg");

var dgOptions = {
        rownumbers:true,
    	fit:true,
    	border:false,
        rownumbers:true,
    	url:'listData',
    	method:'post',
    	toolbar:'#tb',
    	pageSize: 10,
    	pagination:true,
    	multiSort:true,
    	columnfit:true,
        queryParams: getInitParam(),
        
        columns: [[
		          {field:'mat_no', title: '物料编号', width:'10%', sortable: true}
	           	 ,{field:'mat_name', title: '物料名称', width:'10%', sortable: true}	           	          
	           	 ,{field:'mat_std', title: '规格', width:'25%', sortable: true}	           	 
	           	 ,{field:'mat_num', title: '当前库存', width:'10%', sortable: true}	
	           	 ,{field:'storage_name', title: '所在仓库', width:'10%', sortable: true}
	           	 ,{field:'loc_name', title: '所在库位', width:'10%', sortable: true}
	             ,{field:'tp_no', title: '托盘位置', width:'10%', sortable: true}	
	           	 ,{field:'in_time', title: '入库时间', width:'15%', sortable: true}	  
	           	 	
	           ]]
	};
$(function() {
	handleAuthDataRule();
	datagrid.datagrid(dgOptions);
});

function zcurdSearch() {
	var param = zcurdGetParam();
	datagrid.datagrid("load", {
		queryParams: param
	})
}

function zcurdGetParam() {
	var param = {};
	$("#tb :input[name]").each(function(i, item) {
		if($(item).val()) {
			param[$(item).attr("name")] = $(item).val();	
		}
	});
	return param;
}

function getInitParam() {
	var param = {};
	$("#tb :input[name]").each(function(i, item) {
		if($(item).val()) {
			param["queryParams[" + $(item).attr("name") + "]"] = $(item).val();	
		}
	});
	return param;
}

var initPara = zcurdGetParam();
function add() {
	top.window.subPage.loadCurrDatagrid = function() {
		showMsg("增加成功！");
		datagrid.datagrid("load");
	}
	top.openWindow("物料信息表-增加", getCurrUrl("addPage") + "?" + $.param(initPara), {size: '900x600'});
}

function update() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择需要编辑的一条数据！");
		return;
	}
	var id = rowsSel[0].id;
	top.window.subPage.loadCurrDatagrid = function() {
		showMsg("更新成功！");
		datagrid.datagrid("reload");
	}
	top.openWindow("物料信息表-编辑", getCurrUrl("updatePage") + "?id=" + id, {size: '900x600'});
}

function del() {
	var ids = [];
	$.each(datagrid.datagrid("getSelections"), function(i, item) {
		ids.push(item.id);
	});
	if(ids.length < 1) {
		showWarnMsg("请选择需要删除的数据！");
		return;
	}
	confirmMsg("确认删除？", function() {
		$.post("delete", {id: ids}, function(data) {
			showMsg("删除成功！");
			datagrid.datagrid("reload");
		});
	});
}

function detail() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择需要查看的一条数据！");
		return;
	}
	var id = rowsSel[0].id;
	top.openWindow("物料信息表-详情", getCurrUrl("detailPage") + "?id=" + id, {size: '900x600'});
}

function exportCsv() {
	var option = datagrid.datagrid("options");
	var param = option.queryParams;
	param.sortName = option.sortName;
	param.sortOrder = option.sortOrder;
	window.location.href = "exportCsv?" + $.param(param);
}
function importCsv() {
	top.window.subPage.loadCurrDatagrid = function() {
		showMsg("导入成功！");
		datagrid.datagrid("load");
	}
	top.openWindow("物料信息表-导入", getCurrUrl("importCsvPage") + "?" + $.param(initPara), {size: '900x600'});
}
//按钮事件

/**
 * 打开子页
 */
var _openSubPageFlag = false;
function _openSubPage(pageUrl) {
	if(!_openSubPageFlag) {
		$("#subLayout").layout("expand", "east");
		setTimeout(function() {
			$("#subIframe").attr("src", pageUrl);
		}, 600);
		_openSubPageFlag = true;
	}else {
		$("#subIframe").attr("src", pageUrl);
	}
}

//扩展js
</script>

<#include "/common/dialogWindow.html"/>
<#include "/common/foot.html"/>
